<!DOCTYPE html>
<html lang="zh-Hans">
<head>

    <!--[if lt IE 9]>
        <style>body {display: none; background: none !important} </style>
        <meta http-equiv="Refresh" Content="0; url=//outdatedbrowser.com/" />
    <![endif]-->

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="format-detection" content="telephone=no" />
<meta name="author" content="zhengweiMao" />



<meta property="og:type" content="article">
<meta property="og:title" content="1.任务调度框架Quartz-入门">
<meta property="og:url" content="https://maozw.gitee.io/maoge-blog/2018/08/01/花神(maoge)/6.quartz--定时任务框架/1.任务调度框架Quartz-入门/index.html">
<meta property="og:site_name" content="花神">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2018-08-06T15:21:14.528Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="1.任务调度框架Quartz-入门">

<link rel="apple-touch-icon" href= "/apple-touch-icon.png">


    <link rel="alternate" href="/atom.xml" title="花神" type="application/atom+xml">



    <link rel="shortcut icon" href="/favicon.png">



    <link href="//cdn.bootcss.com/animate.css/3.5.1/animate.min.css" rel="stylesheet">



    <link href="//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.css" rel="stylesheet">



    <script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
    <link href="//cdn.bootcss.com/pace/1.0.2/themes/blue/pace-theme-minimal.css" rel="stylesheet">


<link rel="stylesheet" href="/maoge-blog/css/style.css">



<link href="//cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">


<title>1.任务调度框架Quartz-入门 | 花神</title>

<script src="//cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>

<script>
    var yiliaConfig = {
        fancybox: true,
        animate: true,
        isHome: false,
        isPost: true,
        isArchive: false,
        isTag: false,
        isCategory: false,
        fancybox_js: "//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.js",
        scrollreveal: "//cdn.bootcss.com/scrollReveal.js/3.1.4/scrollreveal.min.js",
        search: true
    }
</script>


    <script>
        yiliaConfig.jquery_ui = [true, "//cdn.bootcss.com/jqueryui/1.10.4/jquery-ui.min.js", "//cdn.bootcss.com/jqueryui/1.10.4/css/jquery-ui.min.css"];
    </script>



    <script> yiliaConfig.rootUrl = "\/";</script>






</head>
<body>
  <div id="container">
    <div class="left-col">
    <div class="overlay"></div>
<div class="intrude-less">
    <header id="header" class="inner">
        <a href="/maoge-blog/" class="profilepic">
            <img src="img/avatar.png" class="animated zoomIn">
        </a>
        <hgroup>
          <h1 class="header-author"><a href="/maoge-blog/">zhengweiMao</a></h1>
        </hgroup>

        

        
            <form id="search-form">
            <input type="text" id="local-search-input" name="q" placeholder="search..." class="search form-control" autocomplete="off" autocorrect="off" searchonload="" />
            <i class="fa fa-times" onclick="resetSearch()"></i>
            </form>
            <div id="local-search-result"></div>
            <p class='no-result'>No results found <i class='fa fa-spinner fa-pulse'></i></p>
        


        
            <div id="switch-btn" class="switch-btn">
                <div class="icon">
                    <div class="icon-ctn">
                        <div class="icon-wrap icon-house" data-idx="0">
                            <div class="birdhouse"></div>
                            <div class="birdhouse_holes"></div>
                        </div>
                        <div class="icon-wrap icon-ribbon hide" data-idx="1">
                            <div class="ribbon"></div>
                        </div>
                        
                        <div class="icon-wrap icon-link hide" data-idx="2">
                            <div class="loopback_l"></div>
                            <div class="loopback_r"></div>
                        </div>
                        
                        
                        <div class="icon-wrap icon-me hide" data-idx="3">
                            <div class="user"></div>
                            <div class="shoulder"></div>
                        </div>
                        
                    </div>
                    
                </div>
                <div class="tips-box hide">
                    <div class="tips-arrow"></div>
                    <ul class="tips-inner">
                        <li>菜单</li>
                        <li>标签</li>
                        
                        <li>友情链接</li>
                        
                        
                        <li>关于我</li>
                        
                    </ul>
                </div>
            </div>
        

        <div id="switch-area" class="switch-area">
            <div class="switch-wrap">
                <section class="switch-part switch-part1">
                    <nav class="header-menu">
                        <ul>
                        
                            <li><a href="/maoge-blog/">主页</a></li>
                        
                            <li><a href="/maoge-blog/archives/">所有文章</a></li>
                        
                            <li><a href="/maoge-blog/tags/">标签云</a></li>
                        
                            <li><a href="/maoge-blog/categories/">分类</a></li>
                        
                            <li><a href="/maoge-blog/about/">关于我</a></li>
                        
                        </ul>
                    </nav>
                    <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fa Email" href="mailto:123@123.com" title="Email"></a>
                            
                                <a class="fa GitHub" href="#" title="GitHub"></a>
                            
                                <a class="fa RSS" href="/maoge-blog/atom.xml" title="RSS"></a>
                            
                        </ul>
                    </nav>
                </section>
                
                
                <section class="switch-part switch-part2">
                    <div class="widget tagcloud" id="js-tagcloud">
                        
                    </div>
                </section>
                
                
                
                <section class="switch-part switch-part3">
                    <div id="js-friends">
                    
                      <a class="main-nav-link switch-friends-link" href="https://hexo.io">Hexo</a>
                    
                      <a class="main-nav-link switch-friends-link" href="https://pages.github.com/">GitHub</a>
                    
                      <a class="main-nav-link switch-friends-link" href="http://moxfive.xyz/">MOxFIVE</a>
                    
                    </div>
                </section>
                

                
                
                <section class="switch-part switch-part4">
                
                    <div id="js-aboutme">专注于前端</div>
                </section>
                
            </div>
        </div>
    </header>                
</div>
    </div>
    <div class="mid-col">
      <nav id="mobile-nav">
      <div class="overlay">
          <div class="slider-trigger"></div>
          <h1 class="header-author js-mobile-header hide"><a href="/" title="回到主页">zhengweiMao</a></h1>
      </div>
    <div class="intrude-less">
        <header id="header" class="inner">
            <a href="/maoge-blog/" class="profilepic">
                <img src="img/avatar.png" class="animated zoomIn">
            </a>
            <hgroup>
              <h1 class="header-author"><a href="/maoge-blog/" title="回到主页">zhengweiMao</a></h1>
            </hgroup>
            
            <nav class="header-menu">
                <ul>
                
                    <li><a href="/maoge-blog/">主页</a></li>
                
                    <li><a href="/maoge-blog/archives/">所有文章</a></li>
                
                    <li><a href="/maoge-blog/tags/">标签云</a></li>
                
                    <li><a href="/maoge-blog/categories/">分类</a></li>
                
                    <li><a href="/maoge-blog/about/">关于我</a></li>
                
                <div class="clearfix"></div>
                </ul>
            </nav>
            <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fa Email" target="_blank" href="mailto:123@123.com" title="Email"></a>
                            
                                <a class="fa GitHub" target="_blank" href="#" title="GitHub"></a>
                            
                                <a class="fa RSS" target="_blank" href="/maoge-blog/atom.xml" title="RSS"></a>
                            
                        </ul>
            </nav>
        </header>                
    </div>
    <link class="menu-list" tags="标签" friends="友情链接" about="关于我"/>
</nav>
      <div class="body-wrap"><article id="post-花神(maoge)/6.quartz--定时任务框架/1.任务调度框架Quartz-入门" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/maoge-blog/2018/08/01/花神(maoge)/6.quartz--定时任务框架/1.任务调度框架Quartz-入门/" class="article-date">
      <time datetime="2018-07-31T18:06:00.000Z" itemprop="datePublished">2018-08-01</time>
</a>


    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      1.任务调度框架Quartz-入门
    </h1>
  

      </header>
      
      <div class="article-info article-info-post">
        
    <div class="article-category tagcloud">
    <a class="article-category-link" href="/maoge-blog/categories/quartz/">quartz</a>
    </div>


        
        <div class="clearfix"></div>
      </div>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <p><excerpt in="" index="" |="" 首页摘要=""><br><a id="more"></a></excerpt></p>
<the rest="" of="" contents="" |="" 余下全文="">

<h2 id="1-quartz–定时任务框架-任务调度框架Quartz-入门"><a href="#1-quartz–定时任务框架-任务调度框架Quartz-入门" class="headerlink" title="1.quartz–定时任务框架\任务调度框架Quartz-入门"></a>1.quartz–定时任务框架\任务调度框架Quartz-入门</h2><h4 id="序言"><a href="#序言" class="headerlink" title="序言"></a>序言</h4><p>Quartz是OpenSymphony开源组织在Job scheduling领域又一个开源项目</p>
<hr>
<ul>
<li>撒啊</li>
</ul>
<hr>
<h4 id="Quartz是什么？"><a href="#Quartz是什么？" class="headerlink" title="Quartz是什么？"></a>Quartz是什么？</h4><ul>
<li>Quartz 是一个完全由 Java 编写的开源作业调度框架，为在 Java 应用程序中进行作业调度提供了简单却强大的机制</li>
<li>Quartz 可以与 J2EE 与 J2SE 应用程序相结合也可以单独使用。</li>
<li>Quartz 允许程序开发人员根据时间的间隔来调度作业。</li>
<li>Quartz 实现了作业和触发器的多对多的关系，还能把多个作业与不同的触发器关联。</li>
</ul>
<h4 id="Quartz-核心概念"><a href="#Quartz-核心概念" class="headerlink" title="Quartz 核心概念"></a>Quartz 核心概念</h4><p>&#8195;&#8195;我们需要明白 Quartz 的几个核心概念，这样理解起 Quartz 的原理就会变得简单</p>
<ul>
<li>Job 表示一个工作，要执行的具体内容。此接口中只有一个方法</li>
<li>JobDetail 表示一个具体的可执行的调度程序，Job 是这个可执行程调度程序所要执行的内容，另外 JobDetail 还包含了这个任务调度的方案和策略。 </li>
<li>Trigger 代表一个调度参数的配置，什么时候去调。</li>
<li>Scheduler 代表一个调度容器，一个调度容器中可以注册多个 JobDetail 和 Trigger。当 Trigger 与 JobDetail 组合，就可以被 Scheduler 容器调度了。 </li>
</ul>
<h4 id="Scheduler"><a href="#Scheduler" class="headerlink" title="Scheduler"></a>Scheduler</h4><ul>
<li><p>Scheduler的生命期，从SchedulerFactory创建它时开始，到Scheduler调用shutdown()方法时结束；Scheduler被创建后，可以增加、删除和列举Job和Trigger，以及执行其它与调度相关的操作（如暂停Trigger）。但是，Scheduler只有在调用start()方法后，才会真正地触发trigger（即执行job）</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// define the job and tie it to our HelloJob class</span></span><br><span class="line">JobDetail job = newJob(HelloJob.class)</span><br><span class="line">    .withIdentity(<span class="string">"myJob"</span>, <span class="string">"group1"</span>) <span class="comment">// name "myJob", group "group1"</span></span><br><span class="line">    .build();</span><br><span class="line"></span><br><span class="line"><span class="comment">// Trigger the job to run now, and then every 40 seconds</span></span><br><span class="line">Trigger trigger = newTrigger()</span><br><span class="line">    .withIdentity(<span class="string">"myTrigger"</span>, <span class="string">"group1"</span>)</span><br><span class="line">    .startNow()</span><br><span class="line">    .withSchedule(simpleSchedule()</span><br><span class="line">        .withIntervalInSeconds(<span class="number">40</span>)</span><br><span class="line">        .repeatForever())            </span><br><span class="line">    .build();</span><br><span class="line"></span><br><span class="line"><span class="comment">// Tell quartz to schedule the job using our trigger</span></span><br><span class="line">sched.scheduleJob(job, trigger);</span><br></pre></td></tr></table></figure>
</li>
<li><p>SchedulerBuilder接口的各种实现类，可以定义不同类型的调度计划（schedule）</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> <span class="keyword">static</span> org.quartz.JobBuilder.*;</span><br><span class="line"><span class="keyword">import</span> <span class="keyword">static</span> org.quartz.SimpleScheduleBuilder.*;</span><br><span class="line"><span class="keyword">import</span> <span class="keyword">static</span> org.quartz.CronScheduleBuilder.*;</span><br><span class="line"><span class="keyword">import</span> <span class="keyword">static</span> org.quartz.CalendarIntervalScheduleBuilder.*;</span><br><span class="line"><span class="keyword">import</span> <span class="keyword">static</span> org.quartz.TriggerBuilder.*;</span><br><span class="line"><span class="comment">//DateBuilder类包含很多方法，可以很方便地构造表示不同时间点的java.util.Date实例（如定义下一个小时为偶数的时间点，如果当前时间为9:43:27，则定义的时间为10:00:00）</span></span><br><span class="line"><span class="keyword">import</span> <span class="keyword">static</span> org.quartz.DateBuilder.*;</span><br></pre></td></tr></table></figure>
</li>
<li><p>Quartz 允许程序开发人员根据时间的间隔来调度作业。</p>
</li>
<li>Quartz 实现了作业和触发器的多对多的关系，还能把多个作业与不同的触发器关联。</li>
</ul>
<h4 id="Job"><a href="#Job" class="headerlink" title="Job"></a>Job</h4><p>一个job就是一个实现了Job接口的类，该接口只有一个方法：<br><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">package</span> org.quartz;</span><br><span class="line"></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">interface</span> <span class="title">Job</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">void</span> <span class="title">execute</span><span class="params">(JobExecutionContext var1)</span> <span class="keyword">throws</span> JobExecutionException</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//Job 表示一个工作，要执行的具体内容。：</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">ScheduleJob</span> <span class="keyword">implements</span> <span class="title">Serializable</span>,<span class="title">Job</span> </span>&#123;</span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">execute</span><span class="params">(JobExecutionContext context)</span> <span class="keyword">throws</span> JobExecutionException </span>&#123;</span><br><span class="line">        <span class="comment">// TODO Auto-generated method stub</span></span><br><span class="line"></span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<ul>
<li>当Job的一个trigger被触发（稍后会讲到）时，execute（）方法由调度程序的一个工作线程调用。传递给execute()方法的JobExecutionContext对象向作业实例提供有关其“运行时”环job的一个trigger被触发后（稍后会讲到），execute()方法会被scheduler的一个工作线程调用；传递给execute()方法的JobExecutionContext对象中保存着该job运行时的一些信息 ，执行job的scheduler的引用，触发job的trigger的引用，JobDetail对象引用，以及一些其它信息。</li>
</ul>
<h4 id="JobDetail"><a href="#JobDetail" class="headerlink" title="JobDetail"></a>JobDetail</h4><ul>
<li>Jobs很容易实现，在接口中只有一个“execute”方法。本节主要关注：Job的特点、Job接口的execute方法以及JobDetail。你定义了一个实现Job接口的类，这个类仅仅表明该job需要完成什么类型的任务，除此之外，Quartz还需要知道该Job实例所包含的属性；这将由JobDetail类来完成。</li>
<li>JobDetail对象是在将job加入scheduler时，由客户端程序（你的程序）创建的。它包含job的各种属性设置，以及用于存储job实例状态信息的JobDataMap</li>
<li><p>JobDetail实例是通过JobBuilder类创建的:</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// define the job and tie it to our HelloJob class</span></span><br><span class="line">  JobDetail job = newJob(HelloJob.class)</span><br><span class="line">      .withIdentity(<span class="string">"myJob"</span>, <span class="string">"group1"</span>) <span class="comment">// name "myJob", group "group1"</span></span><br><span class="line">      .build();</span><br><span class="line"></span><br><span class="line">  <span class="comment">// Trigger the job to run now, and then every 40 seconds</span></span><br><span class="line">  Trigger trigger = newTrigger()</span><br><span class="line">      .withIdentity(<span class="string">"myTrigger"</span>, <span class="string">"group1"</span>)</span><br><span class="line">      .startNow()</span><br><span class="line">      .withSchedule(simpleSchedule()</span><br><span class="line">          .withIntervalInSeconds(<span class="number">40</span>)</span><br><span class="line">          .repeatForever())            </span><br><span class="line">      .build();</span><br><span class="line"></span><br><span class="line">  <span class="comment">// Tell quartz to schedule the job using our trigger</span></span><br><span class="line">  sched.scheduleJob(job, trigger);</span><br></pre></td></tr></table></figure>
</li>
<li><p>传给scheduler一个JobDetail实例，因为我们在创建JobDetail时，将要执行的job的类名传给了JobDetail，所以scheduler就知道了要执行何种类型的job；每次当scheduler执行job时，在调用其execute(…)方法之前会创建该类的一个新的实例；执行完毕，对该实例的引用就被丢弃了，实例会被垃圾回收；这种执行策略带来的一个后果是，job必须有一个无参的构造函数（当使用默认的JobFactory时）；另一个后果是，在job类中，不应该定义有状态的数据属性，因为在job的多次执行中，这些属性的值不会保留。</p>
</li>
<li>那么如何给job实例增加属性或配置呢？如何在job的多次执行中，跟踪job的状态呢？答案就是:JobDataMap，JobDetail对象的一部分。<h4 id="JobDataMap"><a href="#JobDataMap" class="headerlink" title="JobDataMap"></a>JobDataMap</h4></li>
<li>JobDataMap中可以包含不限量的（序列化的）数据对象，在job实例执行的时候，可以使用其中的数据；JobDataMap是Java Map接口的一个实现，额外增加了一些便于存取基本类型的数据的方法。</li>
<li><p>将job加入到scheduler之前，在构建JobDetail时，可以将数据放入JobDataMap，如下示例：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// define the job and tie it to our DumbJob class</span></span><br><span class="line">JobDetail job = newJob(DumbJob.class)</span><br><span class="line">    .withIdentity(<span class="string">"myJob"</span>, <span class="string">"group1"</span>) <span class="comment">// name "myJob", group "group1"</span></span><br><span class="line">    .usingJobData(<span class="string">"jobSays"</span>, <span class="string">"Hello World!"</span>)</span><br><span class="line">    .usingJobData(<span class="string">"myFloatValue"</span>, <span class="number">3.141f</span>)</span><br><span class="line">    .build();</span><br></pre></td></tr></table></figure>
</li>
<li><p>在job的执行过程中，可以从JobDataMap中取出数据，如下示例：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">DumbJob</span> <span class="keyword">implements</span> <span class="title">Job</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="title">DumbJob</span><span class="params">()</span> </span>&#123;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">execute</span><span class="params">(JobExecutionContext context)</span></span></span><br><span class="line"><span class="function">      <span class="keyword">throws</span> JobExecutionException</span></span><br><span class="line"><span class="function">    </span>&#123;</span><br><span class="line">      JobKey key = context.getJobDetail().getKey();</span><br><span class="line"></span><br><span class="line">      JobDataMap dataMap = context.getJobDetail().getJobDataMap();</span><br><span class="line"></span><br><span class="line">      String jobSays = dataMap.getString(<span class="string">"jobSays"</span>);</span><br><span class="line">      <span class="keyword">float</span> myFloatValue = dataMap.getFloat(<span class="string">"myFloatValue"</span>);</span><br><span class="line"></span><br><span class="line">      System.err.println(<span class="string">"Instance "</span> + key + <span class="string">" of DumbJob says: "</span> + jobSays + <span class="string">", and val is: "</span> + myFloatValue);</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure>
</li>
</ul>
<blockquote>
<p>如果你使用的是持久化的存储机制（本教程的JobStore部分会讲到），在决定JobDataMap中存放什么数据的时候需要小心，因为JobDataMap中存储的对象都会被序列化，因此很可能会导致类的版本不一致的问题；Java的标准类型都很安全，如果你已经有了一个类的序列化后的实例，某个时候，别人修改了该类的定义，此时你需要确保对类的修改没有破坏兼容性；</p>
</blockquote>
<h4 id="Trigger"><a href="#Trigger" class="headerlink" title="Trigger"></a>Trigger</h4><ul>
<li>Trigger用于触发Job的执行。当你准备调度一个job时，你创建一个Trigger的实例，然后设置调度相关的属性。Trigger也有一个相关联的JobDataMap，用于给Job传递一些触发相关的参数。Quartz自带了各种不同类型的Trigger，最常用的主要是SimpleTrigger和CronTrigger。</li>
<li>SimpleTrigger主要用于一次性执行的Job（只在某个特定的时间点执行一次），或者Job在特定的时间点执行，重复执行N次，每次执行间隔T个时间单位</li>
<li>CronTrigger在基于日历的调度上非常有用，如“每个星期五的正午”，或者“每月的第十天的上午10:15”等。<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">什么既有Job，又有Trigger呢？</span><br><span class="line"> 很多任务调度器并不区分Job和Trigger。有些调度器只是简单地通过一个执行时间和一些job标识符来定义一个Job；其它的一些调度器将Quartz的Job和Trigger对象合二为一。在开发Quartz的时候，我们认为将调度和要调度的任务分离是合理的。在我们看来，这可以带来很多好处。</span><br><span class="line">例如，Job被创建后，可以保存在Scheduler中，与Trigger是独立的，同一个Job可以有多个Trigger；这种松耦合的另一个好处是，当与Scheduler中的Job关联的trigger都过期时，可以配置Job稍后被重新调度，而不用重新定义Job；还有，可以修改或者替换Trigger，而不用重新定义与之关联的Job。</span><br></pre></td></tr></table></figure>
</li>
</ul>
<h4 id="Key-Group"><a href="#Key-Group" class="headerlink" title="Key Group"></a>Key Group</h4><ul>
<li>将Job和Trigger注册到Scheduler时，可以为它们设置key，配置其身份属性。Job和Trigger的key（JobKey和TriggerKey）可以用于将Job和Trigger放到不同的分组（group）里，然后基于分组进行操作。同一个分组下的Job或Trigger的名称必须唯一，即一个Job或Trigger的key由名称（name）和分组（group）组成。</li>
</ul>
<h4 id="使用Quartz"><a href="#使用Quartz" class="headerlink" title="使用Quartz"></a>使用Quartz</h4><p>在使用Scheduler之前，需要实例化。为此，您可以使用SchedulerFactory。Quartz的一些用户可能会在JNDI存储中保留factory的实例，其他用户可能会发现直接初始化会更加简单（例如下面的示例）。<br>scheduler实例化后，可以启动(start)、暂停(stand-by)、停止(shutdown)。注意：scheduler被停止后，除非重新实例化，否则不能重新启动；只有当scheduler启动后，即使处于暂停状态也不行，trigger才会被触发（job才会被执行）。<br>下面的代码片段，实例化并启动一个scheduler，调度执行一个job：<br><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line">SchedulerFactory schedFact = <span class="keyword">new</span> org.quartz.impl.StdSchedulerFactory();</span><br><span class="line"></span><br><span class="line"> Scheduler sched = schedFact.getScheduler();</span><br><span class="line"></span><br><span class="line"> sched.start();</span><br><span class="line"></span><br><span class="line"> <span class="comment">// define the job and tie it to our HelloJob class</span></span><br><span class="line"> JobDetail job = newJob(HelloJob.class)</span><br><span class="line">     .withIdentity(<span class="string">"myJob"</span>, <span class="string">"group1"</span>)</span><br><span class="line">     .build();</span><br><span class="line"></span><br><span class="line"> <span class="comment">// Trigger the job to run now, and then every 40 seconds</span></span><br><span class="line"> Trigger trigger = newTrigger()</span><br><span class="line">     .withIdentity(<span class="string">"myTrigger"</span>, <span class="string">"group1"</span>)</span><br><span class="line">     .startNow()</span><br><span class="line">     .withSchedule(simpleSchedule()</span><br><span class="line">         .withIntervalInSeconds(<span class="number">40</span>)</span><br><span class="line">         .repeatForever())</span><br><span class="line">     .build();</span><br><span class="line"></span><br><span class="line"> <span class="comment">// Tell quartz to schedule the job using our trigger</span></span><br><span class="line"> sched.scheduleJob(job, trigger);</span><br></pre></td></tr></table></figure></p>
</the>
      
    </div>
    
  </div>
  
    
    <div class="copyright">
        <p><span>本文标题:</span><a href="/maoge-blog/2018/08/01/花神(maoge)/6.quartz--定时任务框架/1.任务调度框架Quartz-入门/">1.任务调度框架Quartz-入门</a></p>
        <p><span>文章作者:</span><a href="/" title="回到主页">zhengweiMao</a></p>
        <p><span>发布时间:</span>2018-08-01, 02:06:00</p>
        <p><span>最后更新:</span>2018-08-06, 23:21:14</p>
        <p>
            <span>原始链接:</span><a class="post-url" href="/maoge-blog/2018/08/01/花神(maoge)/6.quartz--定时任务框架/1.任务调度框架Quartz-入门/" title="1.任务调度框架Quartz-入门">https://maozw.gitee.io/maoge-blog/2018/08/01/花神(maoge)/6.quartz--定时任务框架/1.任务调度框架Quartz-入门/</a>
            <span class="copy-path" data-clipboard-text="原文: https://maozw.gitee.io/maoge-blog/2018/08/01/花神(maoge)/6.quartz--定时任务框架/1.任务调度框架Quartz-入门/　　作者: zhengweiMao" title="点击复制文章链接"><i class="fa fa-clipboard"></i></span>
            <script> var clipboard = new Clipboard('.copy-path'); </script>
        </p>
        <p>
            <span>许可协议:</span><i class="fa fa-creative-commons"></i> <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" title="CC BY-NC-SA 4.0 International" target = "_blank">"署名-非商用-相同方式共享 4.0"</a> 转载请保留原文链接及作者。
        </p>
    </div>



    <nav id="article-nav">
        
            <div id="article-nav-newer" class="article-nav-title">
                <a href="/maoge-blog/2018/08/01/花神(maoge)/6.quartz--定时任务框架/2-1.任务调度框架Quartz-Triggers详解理解/">
                    2-1.任务调度框Quartz-Triggers详解理解
                </a>
            </div>
        
        
            <div id="article-nav-older" class="article-nav-title">
                <a href="/maoge-blog/2018/07/12/花神(maoge)/9.Spring/SpringMVC--源码解读/05.SpringMVC-----源码分析与实践--HandlerMapping(1)/">
                    1.SpringMVC -源码分析与实践-HandlerMapping
                </a>
            </div>
        
    </nav>

  
</article>

    <div id="toc" class="toc-article">
        <strong class="toc-title">文章目录</strong>
        
            <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-quartz–定时任务框架-任务调度框架Quartz-入门"><span class="toc-number">1.</span> <span class="toc-text">1.quartz–定时任务框架\任务调度框架Quartz-入门</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#序言"><span class="toc-number">1.0.1.</span> <span class="toc-text">序言</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#Quartz是什么？"><span class="toc-number">1.0.2.</span> <span class="toc-text">Quartz是什么？</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#Quartz-核心概念"><span class="toc-number">1.0.3.</span> <span class="toc-text">Quartz 核心概念</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#Scheduler"><span class="toc-number">1.0.4.</span> <span class="toc-text">Scheduler</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#Job"><span class="toc-number">1.0.5.</span> <span class="toc-text">Job</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#JobDetail"><span class="toc-number">1.0.6.</span> <span class="toc-text">JobDetail</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#JobDataMap"><span class="toc-number">1.0.7.</span> <span class="toc-text">JobDataMap</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#Trigger"><span class="toc-number">1.0.8.</span> <span class="toc-text">Trigger</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#Key-Group"><span class="toc-number">1.0.9.</span> <span class="toc-text">Key Group</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#使用Quartz"><span class="toc-number">1.0.10.</span> <span class="toc-text">使用Quartz</span></a></li></ol></li></ol></li></ol>
        
    </div>
    <style>
        .left-col .switch-btn,
        .left-col .switch-area {
            display: none;
        }
        .toc-level-3 i,
        .toc-level-3 ol {
            display: none !important;
        }
    </style>

    <input type="button" id="tocButton" value="隐藏目录"  title="点击按钮隐藏或者显示文章目录">

    <script>
        yiliaConfig.toc = ["隐藏目录", "显示目录", !!"false"];
    </script>



    
<div class="share">
    
        <div class="bdsharebuttonbox">
            <a href="#" class="fa fa-twitter bds_twi" data-cmd="twi" title="分享到推特"></a>
            <a href="#" class="fa fa-weibo bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
            <a href="#" class="fa fa-qq bds_sqq" data-cmd="sqq" title="分享给 QQ 好友"></a>
            <a href="#" class="fa fa-files-o bds_copy" data-cmd="copy" title="复制网址"></a>
            <a href="#" class="fa fa fa-envelope-o bds_mail" data-cmd="mail" title="通过邮件分享"></a>
            <a href="#" class="fa fa-weixin bds_weixin" data-cmd="weixin" title="生成文章二维码"></a>
            <a href="#" class="fa fa-share-alt bds_more" data-cmd="more"></i></a>
        </div>
        <script>
            window._bd_share_config={
                "common":{"bdSnsKey":{},"bdText":"1.任务调度框架Quartz-入门　| 花神　","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
        </script>
    

    
</div>







    




    <div class="scroll" id="post-nav-button">
        
            <a href="/maoge-blog/2018/08/01/花神(maoge)/6.quartz--定时任务框架/2-1.任务调度框架Quartz-Triggers详解理解/" title="上一篇: 2-1.任务调度框Quartz-Triggers详解理解">
                <i class="fa fa-angle-left"></i>
            </a>
        

        <a title="文章列表"><i class="fa fa-bars"></i><i class="fa fa-times"></i></a>

        
            <a href="/maoge-blog/2018/07/12/花神(maoge)/9.Spring/SpringMVC--源码解读/05.SpringMVC-----源码分析与实践--HandlerMapping(1)/" title="下一篇: 1.SpringMVC -源码分析与实践-HandlerMapping">
                <i class="fa fa-angle-right"></i>
            </a>
        
    </div>

    <ul class="post-list"><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/08/05/花神(maoge)/9.Spring/SpringBoot/SpringBoot-启动源码解析/">1.SpringBoot源码分析之SpringBoot的启动过程</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/08/05/花神(maoge)/11.java-reflections/2.反射框架--reflections-抓取实例/">1.反射框架--reflections-抓取实例</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/08/05/花神(maoge)/11.服务器相关/1.服务器--Sigar 获取CPU和Memory内存等信息使用详解/">1.Sigar 获取CPU和Memory内存等信息使用详解</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/08/05/花神(maoge)/11.java-reflections/1.反射框架--reflections-基本介绍/">1.反射框架--reflections-基本介绍</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/08/05/花神(maoge)/10.算法/算法----外部排序/">2.算法 -外部排序</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/08/05/花神(maoge)/10.算法/算法----snowflake/">1.算法 -snowflake</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/08/05/花神(maoge)/8.面试/面试/">1.面试</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/08/01/花神(maoge)/6.quartz--定时任务框架/7.Quartz-Job状态与并发/">7.任务调度框架Quartz-Job状态与并发</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/08/01/花神(maoge)/6.quartz--定时任务框架/6.任务调度框架Quartz-config/">5.任务调度框架Quartz-Quartz-Job Stores</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/08/01/花神(maoge)/6.quartz--定时任务框架/5.任务调度框架Quartz-Job Stores/">5.任务调度框架Quartz-Quartz-Job Stores</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/08/01/花神(maoge)/6.quartz--定时任务框架/4.任务调度框架Quartz-SchedulerListeners/">4.任务调度框架Quartz-SchedulerListeners</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/08/01/花神(maoge)/6.quartz--定时任务框架/3.任务调度框架Quartz-TriggerListeners和JobListeners/">3.任务调度框架Quartz-Triggers-SimpleTrigger</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/08/01/花神(maoge)/6.quartz--定时任务框架/2-3.任务调度框架Quartz-Triggers-CronTrigger/">2-2.任务调度框架Quartz-Triggers-CronTrigger</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/08/01/花神(maoge)/6.quartz--定时任务框架/2-2.任务调度框架Quartz-Triggers-SimpleTrigger/">2-2.任务调度框架Quartz-Triggers-SimpleTrigger</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/08/01/花神(maoge)/6.quartz--定时任务框架/2-1.任务调度框架Quartz-Triggers详解理解/">2-1.任务调度框Quartz-Triggers详解理解</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/08/01/花神(maoge)/6.quartz--定时任务框架/1.任务调度框架Quartz-入门/">1.任务调度框架Quartz-入门</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/12/花神(maoge)/9.Spring/SpringMVC--源码解读/05.SpringMVC-----源码分析与实践--HandlerMapping(1)/">1.SpringMVC -源码分析与实践-HandlerMapping</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/12/花神(maoge)/9.Spring/SpringMVC--源码解读/04.SpringMVC-----源码分析与实践--DispatcherServlet核心/">4.SpringMVC -源码分析与实践-DispatcherServlet</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/12/花神(maoge)/9.Spring/SpringMVC--源码解读/03.SpringMVC-----源码分析与实践--初始化分析/">3.SpringMVC -初始化源码分析</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/12/花神(maoge)/9.Spring/SpringMVC--源码解读/02.SpringMVC-----源码分析与实践--环境搭建/">2.SpringMVC -源码分析与实践--环境搭建</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/12/花神(maoge)/7.JAVA_WEB相关技术/1.基于AsyncRestTemplate异步HTTP请求的一种轻量级技术实现/">1.基于AsyncRestTemplate异步HTTP请求的一种轻量级技术实</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/12/花神(maoge)/9.Spring/SpringMVC--源码解读/01.SpringMVC-----源码分析与实践----初步认知/">1.SpringMVC -源码分析与实践----初步认知</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/05/花神(maoge)/1.并发编程/20.并发编程--并发框架-Disruptor--应用示例3/">20.并发编程--并发框架-Disruptor--应用示例3</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/05/花神(maoge)/1.并发编程/19.并发编程--并发框架-Disruptor--应用示例2/">19并发编程--并发框架-Disruptor--应用示例2</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/05/花神(maoge)/1.并发编程/18.并发编程--并发框架-Disruptor--应用示例1/">18.并发编程--并发框架-Disruptor--应用示例1</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/05/花神(maoge)/1.并发编程/17.并发编程--并发框架-Disruptor--术语介绍/">17.并发编程--并发框架-Disruptor--介绍</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/05/花神(maoge)/1.并发编程/16.并发编程--并发框架-Disruptor--入门介绍/">16.并发编程--并发框架-Disruptor--介绍</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/05/花神(maoge)/1.并发编程/15.并发编程--锁-介绍/">15.并发编程--锁-介绍</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/05/花神(maoge)/1.并发编程/14.并发编程--Concurrent-工具类/">14.并发编程--Concurrent-工具类介绍</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/05/花神(maoge)/1.并发编程/13.并发编程--线程池介绍/">13. 并发编程--线程池</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/05/花神(maoge)/1.并发编程/12.并发编程--多线程设计模式 - 生产者-消费者模式/">12并发编程\12.并发编程--多线程设计模式 - 生产者-消费者模式</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/05/花神(maoge)/1.并发编程/11.并发编程--多线程设计模式 - Master-Worker模式/">11多线程设计模式 - Master-Worker模式</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/05/花神(maoge)/1.并发编程/7.并发编程--单例模式(饥饿模式-懒汉模式)/">7.并发编程--单例模式(饥饿模式-懒汉模式)</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/05/花神(maoge)/1.并发编程/10.并发编程--多线程设计模式 - Future模式/">10 多线程设计模式 - Future模式</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/05/花神(maoge)/1.并发编程/8.并发编程--同步类容器和并发类容器/">8并发编程--同步类容器和并发类容器</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/05/花神(maoge)/1.并发编程/6.并发编程--ThreadLocal/">6.并发编程--ThreadLocal</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/05/花神(maoge)/1.并发编程/9.并发编程--Queue/">9并发编程--Queue</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/05/花神(maoge)/1.并发编程/5.并发编程--多线程通信-wait-notify-模拟Queue/">并发编程--多线程通信-wait-notify-模拟Queue</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/05/花神(maoge)/1.并发编程/4-2.并发编程--多线程通信-wait-notify-notifyAll-join/">4-2.并发编程--并发编程--多线程通信-wait-notify-notifyAll-join</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/05/花神(maoge)/1.并发编程/4-1.并发编程--多线程通信-wait-notify/">4.并发编程--多线程通信-wait-notify</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/05/花神(maoge)/1.并发编程/1.并发编程--线程基础/">并发编程--线程基础</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/05/花神(maoge)/1.并发编程/3.并发编程--volatile 细节说明/">并发编程--volatile</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/05/花神(maoge)/1.并发编程/2.并发编程-synchronized 细节说明/">并发编程-synchronized 细节说明</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/07/05/花神(maoge)/1.并发编程/0.并发编程-readMe/">并发编程</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/05/05/花神(maoge)/2.网络编程/0.并发编程-readMe/">网络编程</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/05/05/花神(maoge)/2.网络编程/13.网络编程--Netty-文件的上传和下载/">13.网络编程--Netty-文件的上传和下载</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/05/05/花神(maoge)/2.网络编程/14.网络编程--mina-入门/">14.网络编程--mina-入门</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/05/05/花神(maoge)/2.网络编程/12.网络编程--Netty-实践-心跳检测/">12.网络编程--Netty-实践-心跳检测</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/05/05/花神(maoge)/2.网络编程/11.网络编程--Netty-实践-数据通信/">11.网络编程--Netty-实践-数据通信+心跳检测</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/05/05/花神(maoge)/2.网络编程/10.网络编程--Netty-基础-WebSocket/">10.网络编程--Netty-基础-WebSocket</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/05/05/花神(maoge)/2.网络编程/9.网络编程--Netty-基础-UDP/">9.网络编程--Netty-UDP</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/05/05/花神(maoge)/2.网络编程/8.网络编程--Netty-基础-拆包粘包-2/">8.网络编程--Netty-拆包粘包</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/05/05/花神(maoge)/2.网络编程/7.网络编程--Netty-基础-拆包粘包-1/">7.网络编程--Netty-拆包粘包</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/05/05/花神(maoge)/2.网络编程/6.网络编程--Netty-基础-HelloWorld/">6.网络编程--Netty-HelloWorld</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/05/05/花神(maoge)/2.网络编程/5.网络编程--Netty-基础-入门/">5.网络编程--Netty-入门</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/05/05/花神(maoge)/2.网络编程/4.网络编程--基础-AIO异步实现/">4.网络编程--基础-AIO异步实现</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/05/05/花神(maoge)/2.网络编程/3.网络编程--基础-NIO异步实现/">3.网络编程--基础-NIO异步实现</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/05/05/花神(maoge)/2.网络编程/2.网络编程--基础-BIO伪异步实现/">网络编程--基础</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/05/05/花神(maoge)/2.网络编程/1.网络编程--基础-socket/">网络编程--基础</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/04/05/花神(maoge)/5.分布式--zookeeper/2.zookeeper--集群搭建/">2.分布式--zookeeper\2.zookeeper--集群搭建</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/04/05/花神(maoge)/5.分布式--zookeeper/1.zookeeper--简介/">1.分布式--zookeeper--zookeeper简介</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/02/05/花神(maoge)/4.JVM相关/1.jvm虚拟机组成部分/">1.jvm虚拟机组成部分</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/02/05/花神(maoge)/3.缓存-中间件/Redis 配置文件说明/">Redis集群搭建-配置文件</a></li><li class="post-list-item"><a class="post-list-link" href="/maoge-blog/2018/02/05/花神(maoge)/3.缓存-中间件/Redis----集群搭建/">Redis集群搭建-实践</a></li></ul>




    <script>
        
    </script>
</div>
      <footer id="footer">
    <div class="outer">
        <div id="footer-info">
            <div class="footer-left">
                <i class="fa fa-copyright"></i> 
                2016-2018 zhengweiMao
            </div>
            <div class="footer-right">
                <a href="http://hexo.io/" target="_blank" title="快速、简洁且高效的博客框架">Hexo</a>  Theme <a href="https://github.com/MOxFIVE/hexo-theme-yelee" target="_blank" title="简而不减 Hexo 双栏博客主题  v3.5">Yelee</a> by MOxFIVE <i class="fa fa-heart animated infinite pulse"></i>
            </div>
        </div>
        
            <div class="visit">
                
                    <span id="busuanzi_container_site_pv" style='display:none'>
                        <span id="site-visit" title="本站到访数"><i class="fa fa-user" aria-hidden="true"></i><span id="busuanzi_value_site_uv"></span>
                        </span>
                    </span>
                
                
                    <span>| </span>
                
                
                    <span id="busuanzi_container_page_pv" style='display:none'>
                        <span id="page-visit"  title="本页阅读量"><i class="fa fa-eye animated infinite pulse" aria-hidden="true"></i><span id="busuanzi_value_page_pv"></span>
                        </span>
                    </span>
                
            </div>
        
    </div>
</footer>
    </div>
    
<script data-main="/maoge-blog/js/main.js" src="//cdn.bootcss.com/require.js/2.2.0/require.min.js"></script>

    <script>
        $(document).ready(function() {
            var iPad = window.navigator.userAgent.indexOf('iPad');
            if (iPad > -1 || $(".left-col").css("display") === "none") {
                var bgColorList = ["#9db3f4", "#414141", "#e5a859", "#f5dfc6", "#c084a0", "#847e72", "#cd8390", "#996731"];
                var bgColor = Math.ceil(Math.random() * (bgColorList.length - 1));
                $("body").css({"background-color": bgColorList[bgColor], "background-size": "cover"});
            }
            else {
                var backgroundnum = 5;
                var backgroundimg = "url(/background/bg-x.jpg)".replace(/x/gi, Math.ceil(Math.random() * backgroundnum));
                $("body").css({"background": backgroundimg, "background-attachment": "fixed", "background-size": "cover"});
            }
        })
    </script>





<div class="scroll" id="scroll">
    <a href="#" title="返回顶部"><i class="fa fa-arrow-up"></i></a>
    <a href="#comments" onclick="load$hide();" title="查看评论"><i class="fa fa-comments-o"></i></a>
    <a href="#footer" title="转到底部"><i class="fa fa-arrow-down"></i></a>
</div>
<script>
    // Open in New Window
    
        var oOpenInNew = {
            
            
            
            
            
            
             archives: ".archive-article-title", 
             miniArchives: "a.post-list-link", 
            
             friends: "#js-friends a", 
             socail: ".social a" 
        }
        for (var x in oOpenInNew) {
            $(oOpenInNew[x]).attr("target", "_blank");
        }
    
</script>

<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>
  </div>
</body>
</html>